.ORG 0
	 LDI R31, HIGH(RAMEND); setup stack from RAM_END
	 OUT SPH, R31
	 LDI R31, LOW (RAMEND)
	 OUT SPL, R31
	 LDI R17, 0X14; COUNTER=20
	 LDI R18, 0X03; number 3
	 LDI R19, 0X05; number 5
	 LDI R20, LOW(0X0000); R20:R21
	 LDI R21, HIGH(0X0000)
	 LDI R23, LOW(0X0000); R23:R24
	 LDI R24, HIGH(0X0000)
	 LDI R26, 0
	 LDI R16, 0X20;i choose 32 to be my first number
 L1: 	 MOV R31, R16; push number into stack
	 PUSH R16
	 INC R16 ; increase the number
	 DEC R17; decrease the counter
	 BRNE L1; if the counter not zero keep add number
	 LDI R22, 0 
	 LDI R17, 0X15 ;store counter because the i will decrees counter first so set it                        to 0x15
L2: 
	 LDI R25, 0
	 LDI R27, 0
	 DEC R17     ; decrement counter 
	 CP R17, R22    ; check if all 20 numbers  
     BREQ GAMEOVER   ; end the loop if all done
	 POP R31; pop the value
	 MOV R15, R31 ;store the pop value
	 MOV R25, R15; store the number that i need to verify if the number can be divided by 3
	 JMP L3; 
L3:  SUB R25, R18; subtract 3
	 BREQ SUM ; if the solution is 0, go to SUM
	 BRLO SUM; if the solution is negative, go to SUM
	 BRPL L3; if not go back L3 

SUM:    MOV R27, R15 ;store the number that i need to verify if the number can be divided by 5
	 SUB R25, R26;use the solution in L3 to check that the solution is negative or zero
	 BRNE L4; if it negative go to L4
	 ADD R20, R15; if it is zero add the original number to R20
	 RJMP L4; go to L4
 
L4:  SUB R27, R19; subtract 5
	 BREQ SUM2; if the solution is zero, go to SUM2
	 BRLO SUM2; if the solution is negative, go to SUM2
	 BRPL L4; if not go back L4

SUM2: SUB R27, R26; use the solution in L4 to check the solution is negative or zero
	  BRNE L2; if it negative go to L2
	  ADD R23, R15; if it is zero add the original number to R23
	  RJMP L2
 
GAMEOVER:



 RET
 
